package at.fhv.framework.filter;

import at.fhv.framework.interfaces.Push;

/**
 * @author Michael
 * @version 1.0
 * @created 16-Nov-2011 10:05:24
 */
public abstract class PassivePushFilter<IN, OUT> extends Filter<IN, OUT>
		implements Push<IN> {

	protected Push<OUT> _target;

	public PassivePushFilter(Push<OUT> target) {
		_target = target;
	}

	/**
	 * T data = execute(); _target.write(data)
	 * 
	 * @param data
	 */
	@Override
	public void write(IN data) {
		OUT entity = createEntity();
		boolean isFull;
		do {
			isFull = execute(entity, data);
		} while (!isFull);

		_target.write(entity);
	}
}